package com.fr.dialog.core;

import com.fr.base.Inter;
import com.fr.base.core.GraphHelper;
import com.fr.cell.core.layout.LayoutFactory;
import com.fr.dialog.BasicPane;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D.Double;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class DetailColorSelectPane extends BasicPane
{
  private ColorSelectPane colorSelectPane;
  private JLabel colorPreviewLabel;
  ChangeListener colorPreviewLabelChangeListener = new ChangeListener(this)
  {
    private final DetailColorSelectPane this$0;

    public void stateChanged()
    {
      DetailColorSelectPane.access$100(this.this$0).setBackground(DetailColorSelectPane.access$000(this.this$0).getColor());
    }
  };

  public DetailColorSelectPane()
  {
    setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 4));
    setLayout(LayoutFactory.createBorderLayout());
    JPanel localJPanel1 = new JPanel();
    add(localJPanel1, "West");
    localJPanel1.setLayout(new BoxLayout(localJPanel1, 0));
    JPanel localJPanel2 = new JPanel();
    localJPanel1.add(localJPanel2);
    localJPanel2.setLayout(LayoutFactory.createBorderLayout());
    JLabel localJLabel = new JLabel(Inter.getLocText("Color") + ":");
    localJPanel2.add(localJLabel, "North");
    localJPanel1.add(Box.createHorizontalStrut(4));
    JPanel localJPanel3 = new JPanel();
    localJPanel1.add(localJPanel3);
    localJPanel3.setLayout(LayoutFactory.createBorderLayout());
    this.colorSelectPane = new ColorSelectPane();
    localJPanel3.add(this.colorSelectPane, "North");
    localJPanel1.add(Box.createHorizontalStrut(8));
    JPanel localJPanel4 = new JPanel();
    localJPanel1.add(localJPanel4);
    localJPanel4.setLayout(LayoutFactory.createBorderLayout());
    JPanel localJPanel5 = new JPanel();
    localJPanel4.add(localJPanel5, "North");
    localJPanel5.setLayout(LayoutFactory.createBorderLayout());
    this.colorPreviewLabel = new JLabel(this, "                                        ")
    {
      private final DetailColorSelectPane this$0;

      public void paintComponent()
      {
        super.paintComponent(paramGraphics);
        Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
        localGraphics2D.setPaint(getBackground());
        GraphHelper.fill(localGraphics2D, new Rectangle2D.Double(0.0D, 0.0D, getSize().getWidth(), getSize().getHeight()));
      }
    };
    this.colorPreviewLabel.setFont(new Font(getFont().getFontName(), getFont().getStyle(), getFont().getSize() + 4));
    this.colorPreviewLabel.setBorder(BorderFactory.createEmptyBorder(0, 2, 2, 2));
    localJPanel5.add(this.colorPreviewLabel, "Center");
    localJPanel5.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("Preview")));
    addChangeListener(this.colorPreviewLabelChangeListener);
    populate(Color.white);
  }

  public void populate(Color paramColor)
  {
    this.colorSelectPane.setColor(paramColor);
  }

  public Color update()
  {
    return this.colorSelectPane.getColor();
  }

  public void addChangeListener(ChangeListener paramChangeListener)
  {
    this.colorSelectPane.addChangeListener(paramChangeListener);
  }

  static ColorSelectPane access$000(DetailColorSelectPane paramDetailColorSelectPane)
  {
    return paramDetailColorSelectPane.colorSelectPane;
  }

  static JLabel access$100(DetailColorSelectPane paramDetailColorSelectPane)
  {
    return paramDetailColorSelectPane.colorPreviewLabel;
  }
}